<template>
	<view class="admin">
		<view class="bgDom"></view>
		<view class="adminDom p30">
			<view class="card unser p30 dis">
				<view class="userImg">
					<image :src="userInfo?.user?.avatar" mode="aspectFill"></image>
				</view>
				<view class="userInfo dis">
					<view class="name">{{ userInfo?.user?.nickname }}</view>
					<view class="tagList dis">
						<view class="tagsa" v-for="item in userInfo.userRoles" :key="item">{{ item }}</view>
					</view>
				</view>
			</view>
			<view class="card grid p20">
				<view class="gridTit">系统</view>
				<view class="gridList dis">
					<view class="gridItem dis" @click="goUserAdmin">
						<view class="icon">
							<image src="/admin/static/1.png" mode=""></image>
						</view>
						<view class="value">用户管理</view>
					</view>
					<view class="gridItem dis" @click="goMyVest">
						<view class="icon">
							<image src="/admin/static/2.png" mode=""></image>
						</view>
						<view class="value">我的马甲</view>
					</view>
					<view class="gridItem dis">
						<view class="icon">
							<image src="/admin/static/3.png" mode=""></image>
						</view>
						<view class="value">活码管理</view>
					</view>
					<view class="gridItem dis" @click="goWithCash">
						<view class="icon">
							<image src="/admin/static/4.png" mode=""></image>
						</view>
						<view class="value">提现管理</view>
					</view>
				</view>
			</view>
			<view class="card grid p20">
				<view class="gridTit">设置</view>
				<view class="gridList dis">
					<view class="gridItem dis" @click="goTheme">
						<view class="icon">
							<image src="/admin/static/5.png" mode=""></image>
						</view>
						<view class="value">主题分类</view>
					</view>
					<view class="gridItem dis" @click="goGotOut">
						<view class="icon">
							<image src="/admin/static/6.png" mode=""></image>
						</view>
						<view class="value">敏感词库</view>
					</view>
					<view class="gridItem dis" @click="goWebmaster">
						<view class="icon">
							<image src="/admin/static/7.png" mode=""></image>
						</view>
						<view class="value">站长设置</view>
					</view>
					<view class="gridItem dis" @click="goRestSet">
						<view class="icon">
							<image src="/admin/static/8.png" mode=""></image>
						</view>
						<view class="value">其他设置</view>
					</view>
				</view>
			</view>
			<view class="card grid p20">
				<view class="gridTit">广告</view>
				<view class="gridList dis">
					<!-- <view class="gridItem dis" @click="goBanner">
						<view class="icon">
							<image src="/admin/static/9.png" mode=""></image>
						</view>
						<view class="value">首页轮播图</view>
					</view>
					<view class="gridItem dis" @click="goAdWall">
						<view class="icon">
							<image src="/admin/static/10.png" mode=""></image>
						</view>
						<view class="value">首页广告墙</view>
					</view>
					<view class="gridItem dis" @click="goWcGroup">
						<view class="icon">
							<image src="/admin/static/11.png" mode=""></image>
						</view>
						<view class="value">微信群</view>
					</view> -->
					<view class="gridItem dis" @click="goCrowdWall">
						<view class="icon">
							<image src="/admin/static/12.png" mode=""></image>
						</view>
						<view class="value">万人墙</view>
					</view>
				</view>
			</view>
			<view class="card grid p20">
				<view class="gridTit">审核管理</view>
				<view class="gridList dis">
					<view class="gridItem dis" @click="goRealName">
						<view class="icon">
							<image src="/admin/static/13.png" mode=""></image>
						</view>
						<view class="value">用户实名</view>
						<view class="num" v-if="unread.userOk">{{ unread.userNum }}</view>
					</view>
					<view class="gridItem dis" @click="goPostAudit">
						<view class="icon">
							<image src="/admin/static/14.png" mode=""></image>
						</view>
						<view class="value">帖子审核</view>
						<view class="num" v-if="unread.postOk">{{ unread.postNum }}</view>
					</view>
					<view class="gridItem dis" @click="goRemarkAudit">
						<view class="icon">
							<image src="/admin/static/15.png" mode=""></image>
						</view>
						<view class="value">评论审核</view>
						<view class="num" v-if="unread.remarkOk">{{ unread.remarkNum }}</view>
					</view>
				</view>
			</view>
			<view class="card grid p20">
				<view class="gridTit">举报管理</view>
				<view class="gridList dis">
					<view class="gridItem dis" @click="goPostReport">
						<view class="icon">
							<image src="/admin/static/16.png" mode=""></image>
						</view>
						<view class="value">帖子举报</view>
						<view class="num" v-if="unread.postRepOk">{{ unread.postRepNum }}</view>
					</view>
					<view class="gridItem dis" @click="goRemarkReport">
						<view class="icon">
							<image src="/admin/static/17.png" mode=""></image>
						</view>
						<view class="value">评论举报</view>
						<view class="num" v-if="unread.remarkRepOk">{{ unread.remarkRepNum }}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="changeSchool" @click="goSchool">
			<image src="/admin/static/25.png" mode=""></image>
		</view>
		<view class="bottom">
			<view class="navList">
				<view class="navItem">
					<view class="icon">
						<image src="/admin/static/18.png" mode=""></image>
					</view>
					<view class="value active">工作台</view>
				</view>
				<!-- <view class="navItem">
					<view class="icon">
						<image src="/admin/static/21.png" mode=""></image>
					</view>
					<view class="value">跑腿</view>
				</view> -->
				<view class="navItem" @click="goData">
					<view class="icon">
						<image src="/admin/static/23.png" mode=""></image>
					</view>
					<view class="value">数据看板</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { getUserInfo, getAuditCount, getMessageTip } from '@/config/api.js';
import { ref } from 'vue';
import { onShow, onLoad, onReachBottom } from '@dcloudio/uni-app';
const schoolInfo = ref({});
onLoad((options) => {
	console.log('options', options);
	const schoolStr = uni.getStorageSync('schoolInfo');
	if (!!schoolStr) {
		const school = JSON.parse(schoolStr);
		schoolInfo.value = school;
	}
});
onShow(() => {
	getUserInfoFun();
	getAuditCountFun();
});

// 用户信息
const userInfo = ref({});
const getUserInfoFun = async () => {
	const res = await getUserInfo();
	console.log(res.data);
	if (res.code == 0) {
		userInfo.value = res.data;
	}
};
//待审核数量统计
const unread = ref({});
const getAuditCountFun = async () => {
	const res = await getAuditCount(schoolInfo.value.schoolId, {});
	if (res.code == 0) {
		const newData = {
			userNum: res.data.userIdentityAuditCount > 9 ? '9+' : res.data.userIdentityAuditCount,
			postNum: res.data.threadAuditCount > 9 ? '9+' : res.data.threadAuditCount,
			remarkNum: res.data.threadPostAuditCount > 9 ? '9+' : res.data.threadPostAuditCount,
			postRepNum: res.data.threadPostReportAuditCount > 9 ? '9+' : res.data.threadPostReportAuditCount,
			remarkRepNum: res.data.threadReportAuditCount > 9 ? '9+' : res.data.threadReportAuditCount,
			userOk: res.data.userIdentityAuditCount > 0 ? true : false,
			postOk: res.data.threadAuditCount > 0 ? true : false,
			remarkOk: res.data.threadPostAuditCount > 0 ? true : false,
			postRepOk: res.data.threadPostReportAuditCount > 0 ? true : false,
			remarkRepOk: res.data.threadReportAuditCount > 0 ? true : false
		};
		unread.value = newData;
	}
};

// 学校列表
const goSchool = () => {
	uni.navigateTo({
		url: `/admin/school/school?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 评论举报
const goRemarkReport = () => {
	uni.navigateTo({
		url: `/admin/audit/remarkReport?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 帖子举报
const goPostReport = () => {
	uni.navigateTo({
		url: `/admin/audit/postReport?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 站长设置
const goWebmaster = () => {
	uni.navigateTo({
		url: `/admin/set/Webmaster?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 其他设置
const goRestSet = () => {
	uni.navigateTo({
		url: `/admin/set/restSet?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 用户提现 Withdraw cash
const goWithCash = () => {
	uni.navigateTo({
		url: `/admin/set/withCash?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 评论审核
const goRemarkAudit = () => {
	uni.navigateTo({
		url: `/admin/audit/remarkAudit?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 帖子审核
const goPostAudit = () => {
	uni.navigateTo({
		url: `/admin/audit/postAudit?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 用户实名
const goRealName = () => {
	uni.navigateTo({
		url: `/admin/review/realName?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 敏感词
const goGotOut = () => {
	uni.navigateTo({
		url: `/admin/index/gotOut?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 主题分类
const goTheme = () => {
	uni.navigateTo({
		url: `/admin/index/theme?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 校园万人墙
const goCrowdWall = () => {
	uni.navigateTo({
		url: `/admin/AD/adList?schoolId=${schoolInfo.value.schoolId}`
	});
	// uni.navigateTo({
	// 	url: `/admin/index/crowdWall?schoolId=${schoolInfo.value.schoolId}`
	// });
};
// 微信群
const goWcGroup = () => {
	uni.navigateTo({
		url: `/admin/index/wcGroup?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 广告墙
const goAdWall = () => {
	uni.navigateTo({
		url: `/admin/index/adWall?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 首页轮播图
const goBanner = () => {
	uni.navigateTo({
		url: `/admin/index/banner?schoolId=${schoolInfo.value.schoolId}`
	});
};
// 我的马甲
const goMyVest = () => {
	uni.navigateTo({
		url: '/admin/index/myVest'
	});
};
// 用户管理
const goUserAdmin = () => {
	uni.navigateTo({
		url: '/admin/index/userAdmin'
	});
};
// 去数据看板
const goData = () => {
	uni.redirectTo({
		url: '/admin/data/data'
	});
};
</script>

<style lang="scss" scoped>
.admin {
	position: relative;
	width: 100%;
	.bgDom {
		position: absolute;
		top: 0rpx;
		left: 0rpx;
		width: 100%;
		height: 120rpx;
		background-color: #02b4fa;
		z-index: 0;
	}
	.adminDom {
		position: relative;
		padding-bottom: 120rpx;
		z-index: 1;
		.unser {
			.userImg {
				margin-right: 20rpx;
				width: 90rpx;
				height: 90rpx;
				border-radius: 50%;
				overflow: hidden;
				background-color: #f7f7f7;
			}
			.userInfo {
				flex: 1;
				flex-direction: column;
				justify-content: space-between;
				.name {
					font-weight: 700;
				}
				.tagList {
					flex-wrap: wrap;
					.tagsa {
						margin-top: 5rpx;
						margin-right: 15rpx;
						padding: 5rpx 15rpx;
						border-radius: 10rpx;
						font-size: 26rpx;
						color: #fff;
						background-color: #02b4fa;
					}
				}
			}
		}
		.grid {
			color: #909090;
			font-size: 26rpx;
			.gridList {
				padding-top: 15rpx;
				flex-wrap: wrap;
				// justify-content: center;
				gap: 40rpx;
				.gridItem {
					position: relative;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					width: 130rpx;
					.icon {
						width: 66rpx;
						height: 66rpx;
						overflow: hidden;
					}
					.value {
						margin-top: 15rpx;
					}
					.num {
						position: absolute;
						top: -10rpx;
						right: -10rpx;
						// padding: 5rpx 15rpx;
						// border-radius: 40rpx;
						width: 40rpx;
						height: 40rpx;
						line-height: 40rpx;
						border-radius: 50%;
						text-align: center;
						font-size: 22rpx;
						color: #fff;
						background-color: #e74033;
					}
				}
			}
		}
	}
	.changeSchool {
		position: fixed;
		top: 600rpx;
		left: 16rpx;
		width: 66rpx;
		height: 66rpx;
		// background-color: rgba(0, 0, 0, 0.5);
		z-index: 2;
	}
	.bottom {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		height: 110rpx;
		background: white;
		border-top: 1rpx solid #f0f0f0;
		z-index: 2025;
		.navList {
			display: flex;
			justify-content: space-around;
			align-items: center;
			width: 100%;
			height: 100%;
			.navItem {
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				width: 100rpx;
				height: 100%;
				.icon {
					width: 50rpx;
					height: 50rpx;
				}
				.value {
					font-size: 24rpx;
					color: #666;
				}
				.active {
					color: #00c2fa;
				}
			}
		}
	}
}
</style>
<style>
page {
	background-color: #f7f7f7;
}
image {
	width: 100%;
	height: 100%;
}
.card {
	margin-bottom: 20rpx;
	background-color: #fff;
	border-radius: 15rpx;
}
</style>
